package dao;

import Mysqlcon.Conn;
import pojo.users.User;
import uilt.Scan;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Findpassworddao extends Conn  {


	public static User getinfo(String username2,String tel,String email)throws Exception{


		String org = null;

		String userpassword2 = null;

		String sql="select * from user where username=?";
		PreparedStatement ps = null;

		ps = connection.prepareStatement(sql);

		ps.setString(1, username2);

		boolean flag=false;
		try {
			ResultSet res = ps.executeQuery();
			while (res.next()){
				System.out.println(res.getString("tel")+res.getString("email"));
				if ((tel.equals(res.getString("tel")))&&(email.equals(res.getString("email")))){

					org=res.getString("org");
					tel=res.getString("tel");
					email=res.getString("email");
					userpassword2=res.getString("userpassword");
					flag=true;
					break;
				}
			}
			if (!flag){
				System.out.println("信息输入有误");
			}else{
				System.out.println("找回成功！您的密码是："+userpassword2);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}


		return new User(username2,userpassword2,org,tel,email);




	}



}
